home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Doc / libthread.tex < prev    next >
LaTeX Document  |  1994-08-12  |  3.6 KB  |  [TEXT/R*ch]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: LaTeX Document (document/latex).

You can browse this item here: libthread.tex

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document text default
99% file LaTeX document, ASCII text, with CR line terminators default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[CR] default (weak)


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[R*ch]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 42 75 69 6c 74 2d 69 |\section|{Built-i|
|00000010| 6e 20 4d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |n Module| \sectco|
|00000020| 64 65 7b 74 68 72 65 61 | 64 7d 7d 0d 5c 62 69 6d |de{threa|d}}.\bim|
|00000030| 6f 64 69 6e 64 65 78 7b | 74 68 72 65 61 64 7d 0d |odindex{|thread}.|
|00000040| 0d 54 68 69 73 20 6d 6f | 64 75 6c 65 20 70 72 6f |.This mo|dule pro|
|00000050| 76 69 64 65 73 20 6c 6f | 77 2d 6c 65 76 65 6c 20 |vides lo|w-level |
|00000060| 70 72 69 6d 69 74 69 76 | 65 73 20 66 6f 72 20 77 |primitiv|es for w|
|00000070| 6f 72 6b 69 6e 67 20 77 | 69 74 68 20 6d 75 6c 74 |orking w|ith mult|
|00000080| 69 70 6c 65 0d 74 68 72 | 65 61 64 73 20 28 61 2e |iple.thr|eads (a.|
|00000090| 6b 2e 61 2e 20 5c 64 66 | 6e 7b 6c 69 67 68 74 2d |k.a. \df|n{light-|
|000000a0| 77 65 69 67 68 74 20 70 | 72 6f 63 65 73 73 65 73 |weight p|rocesses|
|000000b0| 7d 20 6f 72 20 5c 64 66 | 6e 7b 74 61 73 6b 73 7d |} or \df|n{tasks}|
|000000c0| 29 20 2d 2d 2d 20 6d 75 | 6c 74 69 70 6c 65 0d 74 |) --- mu|ltiple.t|
|000000d0| 68 72 65 61 64 73 20 6f | 66 20 63 6f 6e 74 72 6f |hreads o|f contro|
|000000e0| 6c 20 73 68 61 72 69 6e | 67 20 74 68 65 69 72 20 |l sharin|g their |
|000000f0| 67 6c 6f 62 61 6c 20 64 | 61 74 61 20 73 70 61 63 |global d|ata spac|
|00000100| 65 2e 20 20 46 6f 72 0d | 73 79 6e 63 68 72 6f 6e |e. For.|synchron|
|00000110| 69 7a 61 74 69 6f 6e 2c | 20 73 69 6d 70 6c 65 20 |ization,| simple |
|00000120| 6c 6f 63 6b 73 20 28 61 | 2e 6b 2e 61 2e 20 5c 64 |locks (a|.k.a. \d|
|00000130| 66 6e 7b 6d 75 74 65 78 | 65 73 7d 20 6f 72 20 5c |fn{mutex|es} or \|
|00000140| 64 66 6e 7b 62 69 6e 61 | 72 79 0d 73 65 6d 61 70 |dfn{bina|ry.semap|
|00000150| 68 6f 72 65 73 7d 29 20 | 61 72 65 20 70 72 6f 76 |hores}) |are prov|
|00000160| 69 64 65 64 2e 0d 0d 54 | 68 65 20 6d 6f 64 75 6c |ided...T|he modul|
|00000170| 65 20 69 73 20 6f 70 74 | 69 6f 6e 61 6c 20 61 6e |e is opt|ional an|
|00000180| 64 20 73 75 70 70 6f 72 | 74 65 64 20 6f 6e 20 53 |d suppor|ted on S|
|00000190| 47 49 20 49 52 49 58 20 | 34 2e 78 20 61 6e 64 20 |GI IRIX |4.x and |
|000001a0| 35 2e 78 20 61 6e 64 20 | 53 75 6e 0d 53 6f 6c 61 |5.x and |Sun.Sola|
|000001b0| 72 69 73 20 32 2e 78 20 | 73 79 73 74 65 6d 73 2c |ris 2.x |systems,|
|000001c0| 20 61 73 20 77 65 6c 6c | 20 61 73 20 6f 6e 20 73 | as well| as on s|
|000001d0| 79 73 74 65 6d 73 20 74 | 68 61 74 20 68 61 76 65 |ystems t|hat have|
|000001e0| 20 61 20 50 54 48 52 45 | 41 44 0d 69 6d 70 6c 65 | a PTHRE|AD.imple|
|000001f0| 6d 65 6e 74 61 74 69 6f | 6e 20 28 65 2e 67 2e 20 |mentatio|n (e.g. |
|00000200| 4b 53 52 29 2e 0d 0d 49 | 74 20 64 65 66 69 6e 65 |KSR)...I|t define|
|00000210| 73 20 74 68 65 20 66 6f | 6c 6c 6f 77 69 6e 67 20 |s the fo|llowing |
|00000220| 63 6f 6e 73 74 61 6e 74 | 20 61 6e 64 20 66 75 6e |constant| and fun|
|00000230| 63 74 69 6f 6e 73 3a 0d | 0d 5c 72 65 6e 65 77 63 |ctions:.|.\renewc|
|00000240| 6f 6d 6d 61 6e 64 7b 5c | 69 6e 64 65 78 73 75 62 |ommand{\|indexsub|
|00000250| 69 74 65 6d 7d 7b 28 69 | 6e 20 6d 6f 64 75 6c 65 |item}{(i|n module|
|00000260| 20 74 68 72 65 61 64 29 | 7d 0d 5c 62 65 67 69 6e | thread)|}.\begin|
|00000270| 7b 65 78 63 64 65 73 63 | 7d 7b 65 72 72 6f 72 7d |{excdesc|}{error}|
|00000280| 0d 52 61 69 73 65 64 20 | 6f 6e 20 74 68 72 65 61 |.Raised |on threa|
|00000290| 64 2d 73 70 65 63 69 66 | 69 63 20 65 72 72 6f 72 |d-specif|ic error|
|000002a0| 73 2e 0d 5c 65 6e 64 7b | 65 78 63 64 65 73 63 7d |s..\end{|excdesc}|
|000002b0| 0d 0d 5c 62 65 67 69 6e | 7b 66 75 6e 63 64 65 73 |..\begin|{funcdes|
|000002c0| 63 7d 7b 73 74 61 72 74 | 5f 6e 65 77 5f 74 68 72 |c}{start|_new_thr|
|000002d0| 65 61 64 7d 7b 66 75 6e | 63 5c 2c 20 61 72 67 7d |ead}{fun|c\, arg}|
|000002e0| 0d 53 74 61 72 74 20 61 | 20 6e 65 77 20 74 68 72 |.Start a| new thr|
|000002f0| 65 61 64 2e 20 20 54 68 | 65 20 74 68 72 65 61 64 |ead. Th|e thread|
|00000300| 20 65 78 65 63 75 74 65 | 73 20 74 68 65 20 66 75 | execute|s the fu|
|00000310| 6e 63 74 69 6f 6e 20 5c | 76 61 72 7b 66 75 6e 63 |nction \|var{func|
|00000320| 7d 0d 77 69 74 68 20 74 | 68 65 20 61 72 67 75 6d |}.with t|he argum|
|00000330| 65 6e 74 20 6c 69 73 74 | 20 5c 76 61 72 7b 61 72 |ent list| \var{ar|
|00000340| 67 7d 20 28 77 68 69 63 | 68 20 6d 75 73 74 20 62 |g} (whic|h must b|
|00000350| 65 20 61 20 74 75 70 6c | 65 29 2e 20 20 57 68 65 |e a tupl|e). Whe|
|00000360| 6e 20 74 68 65 0d 66 75 | 6e 63 74 69 6f 6e 20 72 |n the.fu|nction r|
|00000370| 65 74 75 72 6e 73 2c 20 | 74 68 65 20 74 68 72 65 |eturns, |the thre|
|00000380| 61 64 20 73 69 6c 65 6e | 74 6c 79 20 65 78 69 74 |ad silen|tly exit|
|00000390| 73 2e 20 20 57 68 65 6e | 20 74 68 65 20 66 75 6e |s. When| the fun|
|000003a0| 63 74 69 6f 6e 20 72 61 | 69 73 65 73 0d 74 65 72 |ction ra|ises.ter|
|000003b0| 6d 69 6e 61 74 65 73 20 | 77 69 74 68 20 61 6e 20 |minates |with an |
|000003c0| 75 6e 68 61 6e 64 6c 65 | 64 20 65 78 63 65 70 74 |unhandle|d except|
|000003d0| 69 6f 6e 2c 20 61 20 73 | 74 61 63 6b 20 74 72 61 |ion, a s|tack tra|
|000003e0| 63 65 20 69 73 20 70 72 | 69 6e 74 65 64 20 61 6e |ce is pr|inted an|
|000003f0| 64 0d 74 68 65 6e 20 74 | 68 65 20 74 68 72 65 61 |d.then t|he threa|
|00000400| 64 20 65 78 69 74 73 20 | 28 62 75 74 20 6f 74 68 |d exits |(but oth|
|00000410| 65 72 20 74 68 72 65 61 | 64 73 20 63 6f 6e 74 69 |er threa|ds conti|
|00000420| 6e 75 65 20 74 6f 20 72 | 75 6e 29 2e 0d 5c 65 6e |nue to r|un)..\en|
|00000430| 64 7b 66 75 6e 63 64 65 | 73 63 7d 0d 0d 5c 62 65 |d{funcde|sc}..\be|
|00000440| 67 69 6e 7b 66 75 6e 63 | 64 65 73 63 7d 7b 65 78 |gin{func|desc}{ex|
|00000450| 69 74 5f 74 68 72 65 61 | 64 7d 7b 7d 0d 45 78 69 |it_threa|d}{}.Exi|
|00000460| 74 20 74 68 65 20 63 75 | 72 72 65 6e 74 20 74 68 |t the cu|rrent th|
|00000470| 72 65 61 64 20 73 69 6c | 65 6e 74 6c 79 2e 20 20 |read sil|ently. |
|00000480| 4f 74 68 65 72 20 74 68 | 72 65 61 64 73 20 63 6f |Other th|reads co|
|00000490| 6e 74 69 6e 75 65 20 74 | 6f 20 72 75 6e 2e 0d 5c |ntinue t|o run..\|
|000004a0| 73 74 72 6f 6e 67 7b 43 | 61 76 65 61 74 3a 7d 20 |strong{C|aveat:} |
|000004b0| 63 6f 64 65 20 69 6e 20 | 70 65 6e 64 69 6e 67 20 |code in |pending |
|000004c0| 5c 63 6f 64 65 7b 66 69 | 6e 61 6c 6c 79 7d 20 63 |\code{fi|nally} c|
|000004d0| 6c 61 75 73 65 73 20 69 | 73 20 6e 6f 74 20 65 78 |lauses i|s not ex|
|000004e0| 65 63 75 74 65 64 2e 0d | 5c 65 6e 64 7b 66 75 6e |ecuted..|\end{fun|
|000004f0| 63 64 65 73 63 7d 0d 0d | 5c 62 65 67 69 6e 7b 66 |cdesc}..|\begin{f|
|00000500| 75 6e 63 64 65 73 63 7d | 7b 65 78 69 74 5f 70 72 |uncdesc}|{exit_pr|
|00000510| 6f 67 7d 7b 73 74 61 74 | 75 73 7d 0d 45 78 69 74 |og}{stat|us}.Exit|
|00000520| 20 61 6c 6c 20 74 68 72 | 65 61 64 73 20 61 6e 64 | all thr|eads and|
|00000530| 20 72 65 70 6f 72 74 20 | 74 68 65 20 76 61 6c 75 | report |the valu|
|00000540| 65 20 6f 66 20 74 68 65 | 20 69 6e 74 65 67 65 72 |e of the| integer|
|00000550| 20 61 72 67 75 6d 65 6e | 74 0d 5c 76 61 72 7b 73 | argumen|t.\var{s|
|00000560| 74 61 74 75 73 7d 20 61 | 73 20 74 68 65 20 65 78 |tatus} a|s the ex|
|00000570| 69 74 20 73 74 61 74 75 | 73 20 6f 66 20 74 68 65 |it statu|s of the|
|00000580| 20 65 6e 74 69 72 65 20 | 70 72 6f 67 72 61 6d 2e | entire |program.|
|00000590| 0d 5c 73 74 72 6f 6e 67 | 7b 43 61 76 65 61 74 3a |.\strong|{Caveat:|
|000005a0| 7d 20 63 6f 64 65 20 69 | 6e 20 70 65 6e 64 69 6e |} code i|n pendin|
|000005b0| 67 20 5c 63 6f 64 65 7b | 66 69 6e 61 6c 6c 79 7d |g \code{|finally}|
|000005c0| 20 63 6c 61 75 73 65 73 | 2c 20 69 6e 20 74 68 69 | clauses|, in thi|
|000005d0| 73 20 74 68 72 65 61 64 | 0d 6f 72 20 69 6e 20 6f |s thread|.or in o|
|000005e0| 74 68 65 72 20 74 68 72 | 65 61 64 73 2c 20 69 73 |ther thr|eads, is|
|000005f0| 20 6e 6f 74 20 65 78 65 | 63 75 74 65 64 2e 0d 5c | not exe|cuted..\|
|00000600| 65 6e 64 7b 66 75 6e 63 | 64 65 73 63 7d 0d 0d 5c |end{func|desc}..\|
|00000610| 62 65 67 69 6e 7b 66 75 | 6e 63 64 65 73 63 7d 7b |begin{fu|ncdesc}{|
|00000620| 61 6c 6c 6f 63 61 74 65 | 5f 6c 6f 63 6b 7d 7b 7d |allocate|_lock}{}|
|00000630| 0d 52 65 74 75 72 6e 20 | 61 20 6e 65 77 20 6c 6f |.Return |a new lo|
|00000640| 63 6b 20 6f 62 6a 65 63 | 74 2e 20 20 4d 65 74 68 |ck objec|t. Meth|
|00000650| 6f 64 73 20 6f 66 20 6c | 6f 63 6b 73 20 61 72 65 |ods of l|ocks are|
|00000660| 20 64 65 73 63 72 69 62 | 65 64 20 62 65 6c 6f 77 | describ|ed below|
|00000670| 2e 20 20 54 68 65 0d 6c | 6f 63 6b 20 69 73 20 69 |. The.l|ock is i|
|00000680| 6e 69 74 69 61 6c 6c 79 | 20 75 6e 6c 6f 63 6b 65 |nitially| unlocke|
|00000690| 64 2e 0d 5c 65 6e 64 7b | 66 75 6e 63 64 65 73 63 |d..\end{|funcdesc|
|000006a0| 7d 0d 0d 5c 62 65 67 69 | 6e 7b 66 75 6e 63 64 65 |}..\begi|n{funcde|
|000006b0| 73 63 7d 7b 67 65 74 5f | 69 64 65 6e 74 7d 7b 7d |sc}{get_|ident}{}|
|000006c0| 0d 52 65 74 75 72 6e 20 | 74 68 65 20 60 74 68 72 |.Return |the `thr|
|000006d0| 65 61 64 20 69 64 65 6e | 74 69 66 69 65 72 27 20 |ead iden|tifier' |
|000006e0| 6f 66 20 74 68 65 20 63 | 75 72 72 65 6e 74 20 74 |of the c|urrent t|
|000006f0| 68 72 65 61 64 2e 20 20 | 54 68 69 73 20 69 73 20 |hread. |This is |
|00000700| 61 0d 6e 6f 6e 7a 65 72 | 6f 20 69 6e 74 65 67 65 |a.nonzer|o intege|
|00000710| 72 2e 20 20 49 74 73 20 | 76 61 6c 75 65 20 68 61 |r. Its |value ha|
|00000720| 73 20 6e 6f 20 64 69 72 | 65 63 74 20 6d 65 61 6e |s no dir|ect mean|
|00000730| 69 6e 67 3b 20 69 74 20 | 69 73 20 69 6e 74 65 6e |ing; it |is inten|
|00000740| 64 65 64 20 61 73 20 61 | 0d 6d 61 67 69 63 20 63 |ded as a|.magic c|
|00000750| 6f 6f 6b 69 65 20 74 6f | 20 62 65 20 75 73 65 64 |ookie to| be used|
|00000760| 20 65 2e 67 2e 20 74 6f | 20 69 6e 64 65 78 20 61 | e.g. to| index a|
|00000770| 20 64 69 63 74 69 6f 6e | 61 72 79 20 6f 66 20 74 | diction|ary of t|
|00000780| 68 72 65 61 64 2d 73 70 | 65 63 69 66 69 63 0d 64 |hread-sp|ecific.d|
|00000790| 61 74 61 2e 20 20 54 68 | 72 65 61 64 20 69 64 65 |ata. Th|read ide|
|000007a0| 6e 74 69 66 69 65 72 73 | 20 6d 61 79 20 62 65 20 |ntifiers| may be |
|000007b0| 72 65 63 79 63 6c 65 64 | 20 77 68 65 6e 20 61 20 |recycled| when a |
|000007c0| 74 68 72 65 61 64 20 65 | 78 69 74 73 20 61 6e 64 |thread e|xits and|
|000007d0| 0d 61 6e 6f 74 68 65 72 | 20 74 68 72 65 61 64 20 |.another| thread |
|000007e0| 69 73 20 63 72 65 61 74 | 65 64 2e 0d 5c 65 6e 64 |is creat|ed..\end|
|000007f0| 7b 66 75 6e 63 64 65 73 | 63 7d 0d 0d 4c 6f 63 6b |{funcdes|c}..Lock|
|00000800| 20 6f 62 6a 65 63 74 73 | 20 68 61 76 65 20 74 68 | objects| have th|
|00000810| 65 20 66 6f 6c 6c 6f 77 | 69 6e 67 20 6d 65 74 68 |e follow|ing meth|
|00000820| 6f 64 73 3a 0d 0d 5c 72 | 65 6e 65 77 63 6f 6d 6d |ods:..\r|enewcomm|
|00000830| 61 6e 64 7b 5c 69 6e 64 | 65 78 73 75 62 69 74 65 |and{\ind|exsubite|
|00000840| 6d 7d 7b 28 6c 6f 63 6b | 20 6d 65 74 68 6f 64 29 |m}{(lock| method)|
|00000850| 7d 0d 5c 62 65 67 69 6e | 7b 66 75 6e 63 64 65 73 |}.\begin|{funcdes|
|00000860| 63 7d 7b 61 63 71 75 69 | 72 65 7d 7b 77 61 69 74 |c}{acqui|re}{wait|
|00000870| 66 6c 61 67 7d 0d 57 69 | 74 68 6f 75 74 20 74 68 |flag}.Wi|thout th|
|00000880| 65 20 6f 70 74 69 6f 6e | 61 6c 20 61 72 67 75 6d |e option|al argum|
|00000890| 65 6e 74 2c 20 74 68 69 | 73 20 6d 65 74 68 6f 64 |ent, thi|s method|
|000008a0| 20 61 63 71 75 69 72 65 | 73 20 74 68 65 20 6c 6f | acquire|s the lo|
|000008b0| 63 6b 0d 75 6e 63 6f 6e | 64 69 74 69 6f 6e 61 6c |ck.uncon|ditional|
|000008c0| 6c 79 2c 20 69 66 20 6e | 65 63 65 73 73 61 72 79 |ly, if n|ecessary|
|000008d0| 20 77 61 69 74 69 6e 67 | 20 75 6e 74 69 6c 20 69 | waiting| until i|
|000008e0| 74 20 69 73 20 72 65 6c | 65 61 73 65 64 20 62 79 |t is rel|eased by|
|000008f0| 20 61 6e 6f 74 68 65 72 | 0d 74 68 72 65 61 64 20 | another|.thread |
|00000900| 28 6f 6e 6c 79 20 6f 6e | 65 20 74 68 72 65 61 64 |(only on|e thread|
|00000910| 20 61 74 20 61 20 74 69 | 6d 65 20 63 61 6e 20 61 | at a ti|me can a|
|00000920| 63 71 75 69 72 65 20 61 | 20 6c 6f 63 6b 20 2d 2d |cquire a| lock --|
|00000930| 2d 20 74 68 61 74 27 73 | 20 74 68 65 69 72 0d 72 |- that's| their.r|
|00000940| 65 61 73 6f 6e 20 66 6f | 72 20 65 78 69 73 74 65 |eason fo|r existe|
|00000950| 6e 63 65 29 2c 20 61 6e | 64 20 72 65 74 75 72 6e |nce), an|d return|
|00000960| 73 20 5c 63 6f 64 65 7b | 4e 6f 6e 65 7d 2e 20 20 |s \code{|None}. |
|00000970| 49 66 20 74 68 65 20 69 | 6e 74 65 67 65 72 0d 5c |If the i|nteger.\|
|00000980| 76 61 72 7b 77 61 69 74 | 66 6c 61 67 7d 20 61 72 |var{wait|flag} ar|
|00000990| 67 75 6d 65 6e 74 20 69 | 73 20 70 72 65 73 65 6e |gument i|s presen|
|000009a0| 74 2c 20 74 68 65 20 61 | 63 74 69 6f 6e 20 64 65 |t, the a|ction de|
|000009b0| 70 65 6e 64 73 20 6f 6e | 20 69 74 73 20 76 61 6c |pends on| its val|
|000009c0| 75 65 3a 0d 69 66 20 69 | 74 20 69 73 20 7a 65 72 |ue:.if i|t is zer|
|000009d0| 6f 2c 20 74 68 65 20 6c | 6f 63 6b 20 69 73 20 6f |o, the l|ock is o|
|000009e0| 6e 6c 79 20 61 63 71 75 | 69 72 65 64 20 69 66 20 |nly acqu|ired if |
|000009f0| 69 74 20 63 61 6e 20 62 | 65 20 61 63 71 75 69 72 |it can b|e acquir|
|00000a00| 65 64 0d 69 6d 6d 65 64 | 69 61 74 65 6c 79 20 77 |ed.immed|iately w|
|00000a10| 69 74 68 6f 75 74 20 77 | 61 69 74 69 6e 67 2c 20 |ithout w|aiting, |
|00000a20| 77 68 69 6c 65 20 69 66 | 20 69 74 20 69 73 20 6e |while if| it is n|
|00000a30| 6f 6e 7a 65 72 6f 2c 20 | 74 68 65 20 6c 6f 63 6b |onzero, |the lock|
|00000a40| 20 69 73 0d 61 63 71 75 | 69 72 65 64 20 75 6e 63 | is.acqu|ired unc|
|00000a50| 6f 6e 64 69 74 69 6f 6e | 61 6c 6c 79 20 61 73 20 |ondition|ally as |
|00000a60| 62 65 66 6f 72 65 2e 20 | 20 49 66 20 61 6e 20 61 |before. | If an a|
|00000a70| 72 67 75 6d 65 6e 74 20 | 69 73 20 70 72 65 73 65 |rgument |is prese|
|00000a80| 6e 74 2c 20 74 68 65 0d | 72 65 74 75 72 6e 20 76 |nt, the.|return v|
|00000a90| 61 6c 75 65 20 69 73 20 | 31 20 69 66 20 74 68 65 |alue is |1 if the|
|00000aa0| 20 6c 6f 63 6b 20 69 73 | 20 61 63 71 75 69 72 65 | lock is| acquire|
|00000ab0| 64 20 73 75 63 63 65 73 | 73 66 75 6c 6c 79 2c 20 |d succes|sfully, |
|00000ac0| 30 20 69 66 20 6e 6f 74 | 2e 0d 5c 65 6e 64 7b 66 |0 if not|..\end{f|
|00000ad0| 75 6e 63 64 65 73 63 7d | 0d 0d 5c 62 65 67 69 6e |uncdesc}|..\begin|
|00000ae0| 7b 66 75 6e 63 64 65 73 | 63 7d 7b 72 65 6c 65 61 |{funcdes|c}{relea|
|00000af0| 73 65 7d 7b 7d 0d 52 65 | 6c 65 61 73 65 73 20 74 |se}{}.Re|leases t|
|00000b00| 68 65 20 6c 6f 63 6b 2e | 20 20 54 68 65 20 6c 6f |he lock.| The lo|
|00000b10| 63 6b 20 6d 75 73 74 20 | 68 61 76 65 20 62 65 65 |ck must |have bee|
|00000b20| 6e 20 61 63 71 75 69 72 | 65 64 20 65 61 72 6c 69 |n acquir|ed earli|
|00000b30| 65 72 2c 20 62 75 74 20 | 6e 6f 74 0d 6e 65 63 65 |er, but |not.nece|
|00000b40| 73 73 61 72 69 6c 79 20 | 62 79 20 74 68 65 20 73 |ssarily |by the s|
|00000b50| 61 6d 65 20 74 68 72 65 | 61 64 2e 0d 5c 65 6e 64 |ame thre|ad..\end|
|00000b60| 7b 66 75 6e 63 64 65 73 | 63 7d 0d 0d 5c 62 65 67 |{funcdes|c}..\beg|
|00000b70| 69 6e 7b 66 75 6e 63 64 | 65 73 63 7d 7b 6c 6f 63 |in{funcd|esc}{loc|
|00000b80| 6b 65 64 7d 7b 7d 0d 52 | 65 74 75 72 6e 20 74 68 |ked}{}.R|eturn th|
|00000b90| 65 20 73 74 61 74 75 73 | 20 6f 66 20 74 68 65 20 |e status| of the |
|00000ba0| 6c 6f 63 6b 3a 20 31 20 | 69 66 20 69 74 20 68 61 |lock: 1 |if it ha|
|00000bb0| 73 20 62 65 65 6e 20 61 | 63 71 75 69 72 65 64 20 |s been a|cquired |
|00000bc0| 62 79 20 73 6f 6d 65 0d | 74 68 72 65 61 64 2c 20 |by some.|thread, |
|00000bd0| 30 20 69 66 20 6e 6f 74 | 2e 0d 5c 65 6e 64 7b 66 |0 if not|..\end{f|
|00000be0| 75 6e 63 64 65 73 63 7d | 0d 0d 7b 5c 62 66 20 43 |uncdesc}|..{\bf C|
|00000bf0| 61 76 65 61 74 73 3a 7d | 0d 0d 5c 62 65 67 69 6e |aveats:}|..\begin|
|00000c00| 7b 69 74 65 6d 69 7a 65 | 7d 0d 5c 69 74 65 6d 0d |{itemize|}.\item.|
|00000c10| 54 68 72 65 61 64 73 20 | 69 6e 74 65 72 61 63 74 |Threads |interact|
|00000c20| 20 73 74 72 61 6e 67 65 | 6c 79 20 77 69 74 68 20 | strange|ly with |
|00000c30| 69 6e 74 65 72 72 75 70 | 74 73 3a 20 74 68 65 0d |interrup|ts: the.|
|00000c40| 5c 63 6f 64 65 7b 4b 65 | 79 62 6f 61 72 64 49 6e |\code{Ke|yboardIn|
|00000c50| 74 65 72 72 75 70 74 7d | 20 65 78 63 65 70 74 69 |terrupt}| excepti|
|00000c60| 6f 6e 20 77 69 6c 6c 20 | 62 65 20 72 65 63 65 69 |on will |be recei|
|00000c70| 76 65 64 20 62 79 20 61 | 6e 20 61 72 62 69 74 72 |ved by a|n arbitr|
|00000c80| 61 72 79 0d 74 68 72 65 | 61 64 2e 0d 0d 5c 69 74 |ary.thre|ad...\it|
|00000c90| 65 6d 0d 43 61 6c 6c 69 | 6e 67 20 5c 63 6f 64 65 |em.Calli|ng \code|
|00000ca0| 7b 73 79 73 2e 65 78 69 | 74 28 5c 76 61 72 7b 73 |{sys.exi|t(\var{s|
|00000cb0| 74 61 74 75 73 7d 29 7d | 20 6f 72 20 65 78 65 63 |tatus})}| or exec|
|00000cc0| 75 74 69 6e 67 0d 5c 63 | 6f 64 65 7b 72 61 69 73 |uting.\c|ode{rais|
|00000cd0| 65 20 53 79 73 74 65 6d | 45 78 69 74 2c 20 5c 76 |e System|Exit, \v|
|00000ce0| 61 72 7b 73 74 61 74 75 | 73 7d 7d 20 69 73 20 61 |ar{statu|s}} is a|
|00000cf0| 6c 6d 6f 73 74 20 65 71 | 75 69 76 61 6c 65 6e 74 |lmost eq|uivalent|
|00000d00| 20 74 6f 20 63 61 6c 6c | 69 6e 67 0d 5c 63 6f 64 | to call|ing.\cod|
|00000d10| 65 7b 74 68 72 65 61 64 | 2e 65 78 69 74 5f 70 72 |e{thread|.exit_pr|
|00000d20| 6f 67 28 5c 76 61 72 7b | 73 74 61 74 75 73 7d 29 |og(\var{|status})|
|00000d30| 7d 2c 20 65 78 63 65 70 | 74 20 74 68 61 74 20 74 |}, excep|t that t|
|00000d40| 68 65 20 66 6f 72 6d 65 | 72 20 77 61 79 73 20 6f |he forme|r ways o|
|00000d50| 66 0d 65 78 69 74 69 6e | 67 20 74 68 65 20 65 6e |f.exitin|g the en|
|00000d60| 74 69 72 65 20 70 72 6f | 67 72 61 6d 20 64 6f 20 |tire pro|gram do |
|00000d70| 68 6f 6e 6f 72 20 5c 63 | 6f 64 65 7b 66 69 6e 61 |honor \c|ode{fina|
|00000d80| 6c 6c 79 7d 20 63 6c 61 | 75 73 65 73 20 69 6e 20 |lly} cla|uses in |
|00000d90| 74 68 65 0d 63 75 72 72 | 65 6e 74 20 74 68 72 65 |the.curr|ent thre|
|00000da0| 61 64 20 28 62 75 74 20 | 6e 6f 74 20 69 6e 20 6f |ad (but |not in o|
|00000db0| 74 68 65 72 20 74 68 72 | 65 61 64 73 29 2e 0d 0d |ther thr|eads)...|
|00000dc0| 5c 69 74 65 6d 0d 4e 6f | 74 20 61 6c 6c 20 62 75 |\item.No|t all bu|
|00000dd0| 69 6c 74 2d 69 6e 20 66 | 75 6e 63 74 69 6f 6e 73 |ilt-in f|unctions|
|00000de0| 20 74 68 61 74 20 6d 61 | 79 20 62 6c 6f 63 6b 20 | that ma|y block |
|00000df0| 77 61 69 74 69 6e 67 20 | 66 6f 72 20 49 2f 4f 20 |waiting |for I/O |
|00000e00| 61 6c 6c 6f 77 20 6f 74 | 68 65 72 0d 74 68 72 65 |allow ot|her.thre|
|00000e10| 61 64 73 20 74 6f 20 72 | 75 6e 2c 20 61 6c 74 68 |ads to r|un, alth|
|00000e20| 6f 75 67 68 20 74 68 65 | 20 6d 6f 73 74 20 70 6f |ough the| most po|
|00000e30| 70 75 6c 61 72 20 6f 6e | 65 73 20 28 5c 63 6f 64 |pular on|es (\cod|
|00000e40| 65 7b 73 6c 65 65 70 7d | 2c 0d 5c 63 6f 64 65 7b |e{sleep}|,.\code{|
|00000e50| 72 65 61 64 7d 2c 20 5c | 63 6f 64 65 7b 73 65 6c |read}, \|code{sel|
|00000e60| 65 63 74 7d 29 20 77 6f | 72 6b 20 61 73 20 65 78 |ect}) wo|rk as ex|
|00000e70| 70 65 63 74 65 64 2e 0d | 0d 5c 65 6e 64 7b 69 74 |pected..|.\end{it|
|00000e80| 65 6d 69 7a 65 7d 0d | |emize}. | |
+--------+-------------------------+-------------------------+--------+--------+